﻿using System;
using System.Threading;
using System.Text;
using System.IO.Ports;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using XBee.Communications;
using XBee.Library;

namespace NetDuino.XBee.Test
{
    public class Program
    {
        private static OutputPort OnboardLED;
        private static XBEE _comm;

        public static void Main()
        {
            OnboardLED = new OutputPort(Pins.ONBOARD_LED, initialState: false);
            _comm = new XBEE("COM1", new TestData());
            _comm.OnReciveData += new ReciveDataDelegate(_comm_OnReciveData); 
            
            Thread.Sleep(Timeout.Infinite);
        }

        static void _comm_OnReciveData(ICommunicationData data)
        {
            TestData _data = ((TestData)data);
            OnboardLED.Write(_data.BoolData);
            _comm.Write(new TestData(_data.BoolData));
        }
    }
}
